package cd.cdyb.sms.dao;

import cd.cdyb.sms.domain.MessageRecording;
import cd.cdyb.sms.dto.MessageRecordingStatisticsDto;
import cd.cdyb.sms.dto.query.MessageRecordingQueryDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface MessageRecordingDao extends BaseMapper<MessageRecording> {


    /**
     * 编辑消息记录
     *
     * @param number 编号
     * @param status 状态
     * @param failReason 失败原因
     */
    @Update("update message_recording set status = #{status}, fail_reason = #{failReason} where number = #{number} ")
    void updateMessageRecordingByNumber(@Param("number") String number, @Param("status") Integer status, @Param("failReason") String failReason);


    /**
     * 编辑成功的记录
     *
     * @param list 记录列表
     */
    void updateSuccessMessageRecordingByNumber(@Param("list") List<String> list);

    /**
     *  编辑超时的记录
     *
     * @param list 记录列表
     */
    void updateTimeoutMessageRecordingByNumber(@Param("list") List<String> list);


    /**
     * 客户端统计
     */
    Page<MessageRecordingStatisticsDto> messageRecordingStatisticsPage(@Param("messageRecordingQueryDto") MessageRecordingQueryDto messageRecordingQueryDto, @Param("page") Page<MessageRecordingStatisticsDto> page);

    /**
     * 总数
     */
    MessageRecordingStatisticsDto messageRecordingStatistics(@Param("messageRecordingQueryDto") MessageRecordingQueryDto messageRecordingQueryDto);
}
